﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pgTipoExPostExtPost.aspx.cs" Inherits="EGuayas.Web.Licenciamiento.admin.tabs.pgTipoExPostExtPost" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="~/Resources/css/Style.css" rel="stylesheet" />
    <!-- Load Ext JS -->
    <script src="../../../Resources/js/Global.js"></script>
</head>
<body>
    <form id="Form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
       <ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
        <Items>
                <ext:FormPanel ID="FormPanel1" runat="server" Region="Center" Layout="HBoxLayout">
                <LayoutConfig>
                    <ext:HBoxLayoutConfig Align="Stretch" />
                </LayoutConfig>
                  <Items>
                      <ext:Panel runat="server"  Layout="FitLayout" Flex="1">
                          <Items>
                           <ext:FormPanel
                                ID="forPnlCategor"     
                                Split="true"
                                Title="Configuración"
                                Height="120"
                                runat="server"                            
                                BodyPadding="5"                          
                                ButtonAlign="Center">
                                <FieldDefaults LabelWidth="90" LabelPad="20" LabelSeparator="" />
                                <Items>
                                    <ext:Panel ID="Panel2" runat="server" Border="false" Layout="Form" ColumnWidth=".5" LabelAlign="Top">
                                        <Defaults>                                          
                                            <ext:Parameter Name="MsgTarget" Value="side" />
                                        </Defaults>
                                        <Items>
                                            <ext:Hidden Text="" ID="hdId" Name="Id" runat="server"></ext:Hidden>
                                            <ext:Panel ID="Panel55" runat="server" ColumnWidth="0.5" Border="false" Padding="0">
                                                 <Items>
                                                     <ext:Panel ID="Container3" runat="server"  Border="false" Layout="HBoxLayout">
                                                                        <Items>       
                                                                          <ext:ComboBox runat="server" ID="cbxClasif1" Name="Codigo1"  Width="185"  FieldLabel="Código:  GPG-14-0001-L" LabelWidth="130"  LabelAlign="Left"  AllowBlank="false" Editable="false" >
                                                                            <Items>
                                                                                <ext:ListItem Value="F" Text="F"/>
                                                                                <ext:ListItem Value="D" Text="D"/>
                                                                                <ext:ListItem Value="E" Text="E"/>                                                                                                                                                                     
                                                                            </Items>                                                                                     
                                                                        </ext:ComboBox>  
                                                                        <ext:ComboBox ID="cbxClasif2" runat="server"  Name="Codigo2"  Width="35"  AllowBlank="false" Editable="false" >
	                                                                        <Items>
		                                                                        <ext:ListItem Value="N" Text="N"/>
		                                                                        <ext:ListItem Value="O" Text="O"/>
		                                                                    </Items>                                                                                     
                                                                        </ext:ComboBox> 
                                                                        <ext:ComboBox runat="server" ID="cbxClasif3" Name="Codigo3"  Width="70" AllowBlank="false" Editable="false" >
	                                                                        <Items>
		                                                                        <ext:ListItem Value="PR" Text="PR"/>
		                                                                        <ext:ListItem Value="PU" Text="PU"/>
                                                                                <ext:ListItem Value="MU" Text="MU"/>
                                                                                <ext:ListItem Value="MI" Text="MI"/>
                                                                                <ext:ListItem Value="HC" Text="HC"/>
	                                                                        </Items>                                                                                     
                                                                        </ext:ComboBox> 
                                                                       
                                                                        <ext:TextField Name="CodigoAdd" runat="server" ID="txtCodigoAdd"  Width="90"  LabelSeparator="" AllowBlank="false">                                                                       
                                                                        </ext:TextField>
                                                                    </Items>
                                                                    </ext:Panel>
                                                                      
                                                 </Items>
                                            </ext:Panel>
                                            <ext:ComboBox runat="server" Editable="false" ID="cbbCateg" Name="Categoria"  FieldLabel="Categoria" LabelAlign="Left" LabelWidth="50" AnchorHorizontal="95%" AllowBlank="false">
                                                    <Items>
                                                                <ext:ListItem Value="Cat1" Text="Categoria 1"/>
                                                                <ext:ListItem Value="Cat2" Text="Categoria 2"/>
                                                                <ext:ListItem Value="Cat3" Text="Categoria 3"/>
                                                    </Items>
                                                 <Listeners>
                                                     <Select Handler="pgTipoCat1Cat2.SelectClasificacion(item.getValue());"></Select>
                                                 </Listeners>
                                             </ext:ComboBox>
                                            <ext:ComboBox runat="server" Editable="false" ID="cbbTipo" Name="Tipo"  FieldLabel="Tipo de estudio" LabelAlign="Left" LabelWidth="50" AnchorHorizontal="95%" AllowBlank="false" Hidden="true">
                                                    <Items>
                                                                <ext:ListItem Value="EXPOST" Text="EXPOST"/>
                                                                <ext:ListItem Value="EXTANTES" Text="EXANTES"/>
                                                    </Items>
                                             </ext:ComboBox>
                                            <ext:RadioGroup ID="rdgPoliz" Name="Poliza" Hidden="true"
                                                GroupName="rdgSiNo_group"
                                                runat="server"
                                                Anchor="none"
                                                AllowBlank="false"
                                                FieldLabel="Poliza">
                                                <LayoutConfig>
                                                    <ext:CheckboxGroupLayoutConfig AutoFlex="false" />
                                                </LayoutConfig>
                                                <Defaults>
                                                    <ext:Parameter Name="name" Value="ccType" />
                                                    <ext:Parameter Name="style" Value="margin-right:15px;" />
                                                </Defaults>
                                                <Items>
                                                    <ext:Radio ID="rdSi"
                                                        runat="server"
                                                        InputValue="S"
                                                        BoxLabel="Si" />

                                                    <ext:Radio ID="rdNo"
                                                        runat="server"
                                                        InputValue="N"
                                                        BoxLabel="No" />
                                                   
                            
                                                </Items>
                                            </ext:RadioGroup>
                                            <ext:ComboBox runat="server" Editable="false" ID="cbxEstadoDMA" Name="EstadoDMA" ValueField="Codigo" DisplayField="Nombre" FieldLabel="Resolución" LabelAlign="Left" LabelWidth="50" AnchorHorizontal="95%" AllowBlank="false">
                                                    <Store>
                                                        <ext:Store runat="server" ID="stoEstadosDMA">
                                                            <Model>
                                                                <ext:Model runat="server">
                                                                    <Fields>
                                                                        <ext:ModelField  Name="Id"/>
                                                                        <ext:ModelField  Name="Nombre"/>
                                                                        <ext:ModelField  Name="Codigo"/>
                                                                    </Fields>
                                                                </ext:Model>
                                                            </Model>
                                                        </ext:Store>
                                                    </Store>
                                             </ext:ComboBox>
                                        </Items>
                                    </ext:Panel>
                              </Items>
                                <Listeners>
                                    <ValidityChange Handler="#{btnAceptarCong}.setDisabled(!valid);#{btnModificar}.setDisabled(!valid);" />
                                </Listeners>
                                <Buttons>
                                    <ext:Button runat="server" Text="Aceptar" ID="btnAceptarCong"  Hidden="true">
                                          <DirectEvents>                       
                                                <Click OnEvent="btnConfig_Click">
                                                  <ExtraParams>
                                                        <ext:Parameter Name="Id" Value="#{hdId}.getValue()" Mode="Raw" />
                                                        <ext:Parameter Name="Poliza" Value="#{rdgPoliz}.items.get(0).getGroupValue()" Mode="Raw" />
                                                        <ext:Parameter Name="Catg" Value="#{cbbCateg}.getValue()" Mode="Raw" />
                                                        <ext:Parameter Name="Tipo" Value="#{cbbTipo}.getValue()" Mode="Raw" />
                                                        <ext:Parameter Name="EstadoDMA" Value="#{cbxEstadoDMA}.getValue()" Mode="Raw" />
                                                        <ext:Parameter Name="Codigo1" Value="(#{cbxClasif1}.getValue()!=null)?#{cbxClasif1}.getValue():''" Mode="Raw" />
                                                        <ext:Parameter Name="Codigo2" Value="(#{cbxClasif2}.getValue()!=null)?#{cbxClasif2}.getValue():''" Mode="Raw" />
                                                        <ext:Parameter Name="Codigo3" Value="(#{cbxClasif3}.getValue()!=null)?#{cbxClasif3}.getValue():''" Mode="Raw" />                                                       
                                                      <ext:Parameter Name="CodigoAdd" Value="#{txtCodigoAdd}.getValue()" Mode="Raw" />
                                                    </ExtraParams>
                                                    <EventMask ShowMask="true"></EventMask>
                                                </Click>
                                            </DirectEvents>
                                    </ext:Button>
                                    <ext:Button runat="server" Text="Modificar" ID="btnModificar" Hidden="true">
                                          <DirectEvents>                       
                                                <Click OnEvent="btnConfigUpdate_Click">
                                                  <ExtraParams>
                                                        <ext:Parameter Name="Id" Value="#{hdId}.getValue()" Mode="Raw" />
                                                        <ext:Parameter Name="Poliza" Value="#{rdgPoliz}.items.get(0).getGroupValue()" Mode="Raw" />
                                                        <ext:Parameter Name="Catg" Value="#{cbbCateg}.getValue()" Mode="Raw" />
                                                        <ext:Parameter Name="Tipo" Value="#{cbbTipo}.getValue()" Mode="Raw" />
                                                        <ext:Parameter Name="EstadoDMA" Value="#{cbxEstadoDMA}.getValue()" Mode="Raw" />
                                                        <ext:Parameter Name="Codigo1" Value="(#{cbxClasif1}.getValue()!=null)?#{cbxClasif1}.getValue():''" Mode="Raw" />
                                                        <ext:Parameter Name="Codigo2" Value="(#{cbxClasif2}.getValue()!=null)?#{cbxClasif2}.getValue():''" Mode="Raw" />
                                                        <ext:Parameter Name="Codigo3" Value="(#{cbxClasif3}.getValue()!=null)?#{cbxClasif3}.getValue():''" Mode="Raw" />      
                                                      <ext:Parameter Name="CodigoAdd" Value="#{txtCodigoAdd}.getValue()" Mode="Raw" />
                                                    </ExtraParams>
                                                    <EventMask ShowMask="true"></EventMask>
                                                    <Confirmation ConfirmRequest="True" Message="Esta seguro de realizar esta acción?" Title="Aviso"></Confirmation>
                                                </Click>
                                            </DirectEvents>
                                    </ext:Button>
                                </Buttons>
                                </ext:FormPanel>
                                <ext:Panel runat="server" Flex="1"></ext:Panel>
                          </Items>
                      </ext:Panel>
                       <ext:GridPanel
                                    Region="South"
                                    Flex="1"
                                    Icon="ShapeMoveBack"
                                    Title="Fases"
                                    ID="gpFases"
                                    Height="150"             
                                    runat="server" >
                                    <Store>
                                    <ext:Store ID="Store1" runat="server">
                                        <Model>
                                        <ext:Model ID="Model1" runat="server" IDProperty="Id">
                                            <Fields>                              
                                                    <ext:ModelField Name="Id" Type="String" />
                                                    <ext:ModelField Name="NombreFase" Type="String" />                                                  
                                                    <ext:ModelField Name="CodigoFase" Type="String" />                                                
                                                    <ext:ModelField Name="EstadoFase"  Type="String" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>                                      
                                    <Proxy>
                                    <ext:PageProxy DirectFn="App.direct.BindDataArchivos">
                                        <Reader>
                                            <ext:JsonReader></ext:JsonReader>
                                        </Reader>
                                    </ext:PageProxy>
                                    </Proxy>
                                    </ext:Store>
                                    </Store>
                                    <ColumnModel ID="ColumnModel1" runat="server">
                                        <Columns>
                                            <ext:Column ID="Column1"  runat="server" Text="Nombre" DataIndex="NombreFase" Flex="1"  /> 
                                            <ext:Column ID="Column2"  runat="server" Text="Estado" DataIndex="EstadoFase" Flex="1"  />                                 
                                        </Columns>
                                    </ColumnModel>  
           
                                    <BottomBar>
                                                                     
                                    </BottomBar>            
                                    <Listeners>             
                                    </Listeners>      
                                          
                                    </ext:GridPanel>                

                  </Items>
               </ext:FormPanel>
                             
   
 
      </Items>
        </ext:Viewport>
        <ext:XScript ID="XScript1" runat="server">
            <script type="text/javascript">
                var pgTipoCat1Cat2    = new Object();
                //Cerrar
                pgTipoCat1Cat2.updateCountFases = function (idExp,tipo) {
                    try {
                        if (tipo == "win") {
                            window.parent.App.WucInforme.RefreshCount(idExp, {
                                success: function (result) {
                                    el.destroy();
                                    if (result != numFases) {
                                        Ext.Msg.show({
                                            title: 'Aviso',
                                            msg: 'Información actualizada correctamente',
                                            buttons: Ext.Msg.ERROR,
                                            animEl: 'elId'
                                        });

                                    }
                                },
                                eventMask: {
                                    showMask: true,
                                    minDelay: 500
                                }
                            });
                        }
                        else
                        {
                            App.direct.WucInforme.RefreshCount(idExp, {
                                success: function (result) {
                                    el.destroy();
                                    if (result != numFases) {
                                        Ext.Msg.show({
                                            title: 'Aviso',
                                            msg: '-Información creada correctamente',
                                            buttons: Ext.Msg.ERROR,
                                            animEl: 'elId'
                                        });

                                    }
                                },
                                eventMask: {
                                    showMask: true,
                                    minDelay: 500
                                }
                            });


                        }
                       
                    } catch (jsbug) {
                        AppGlobalJs.showBug("pgTipoCat1Cat2.closeVentana : " + jsbug);
                    }
                };
                pgTipoCat1Cat2.closeVentana = function () {
                    try
                    {
                        Ext.Msg.show({
                            title: 'Aviso',
                            msg: 'Información creada correctamente',
                            buttons: Ext.Msg.ERROR,
                            animEl: 'elId'
                        });
                       
                        var win = Ext.getCmp('winConfigCat1Cat2') || window.parent.App.winConfigCat1Cat2;
                        //win.hide();     
                        //win.destroy();
                        win.close();
                      
                    } catch (jsbug) {
                        AppGlobalJs.showBug("pgTipoCat1Cat2.closeVentana : " + jsbug);
                    }
                }; 
                pgTipoCat1Cat2.SelectClasificacion = function (valSelect) {
                    try
                    {
                         //Limpiar valores al selecionar nuevamente categoria
                         #{rdgPoliz}.reset();
                         #{cbbTipo}.setValue("");
                         #{cbxEstadoDMA}.setValue("");
                        switch (valSelect)
                        {
                            case "Cat1":
                            case "Cat2":
                                #{cbbTipo}.show();                           
                                #{rdgPoliz}.show();
                                #{cbbTipo}.allowBlank = false;
                                #{rdgPoliz}.allowBlank = false;
                                break
                  
                            case "Cat3":                               
                                #{cbbTipo}.hide();
                                #{rdgPoliz}.hide();
                                #{rdgPoliz}.setValue({rdgSiNo_group:'N'});
                                #{cbbTipo}.allowBlank = true;
                                #{rdgPoliz}.allowBlank = true;
                                 
                                break

                        }

                    }catch(jsbug){
                        AppGlobalJs.showBug("pgTipoCat1Cat2.SelectClasificacion: " + jsbug)
                    }
                };
            </script>
        </ext:XScript>
     </form>
</body>
</html>
